{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "08fdfed7-8f70-4479-909a-6123464a5272",
   "metadata": {},
   "source": [
    "# Hadamard Transform\n",
    "\n",
    "The Hadamard transform function applies an H gate on each qubit of the register inputted to the function.\n",
    "\n",
    "Function: `hadamard_transform`\n",
    "\n",
    "Arguments:\n",
    "\n",
    "- `target`: `QArray[QBit]`\n",
    "\n",
    "The `target` quantum argument is the quantum state on which we apply the Hadamard Transform.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4aaa84d1-36c5-4eb3-a713-593d9cc509b3",
   "metadata": {},
   "source": [
    "## Example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d67855d0-5461-4d8e-9f7d-1bc47ca80928",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-05-07T13:25:10.107649Z",
     "iopub.status.busy": "2024-05-07T13:25:10.107213Z",
     "iopub.status.idle": "2024-05-07T13:25:12.859827Z",
     "shell.execute_reply": "2024-05-07T13:25:12.859139Z"
    }
   },
   "outputs": [],
   "source": [
    "from classiq import (\n",
    "    Output,\n",
    "    QArray,\n",
    "    QBit,\n",
    "    allocate,\n",
    "    create_model,\n",
    "    hadamard_transform,\n",
    "    qfunc,\n",
    ")\n",
    "\n",
    "\n",
    "@qfunc\n",
    "def main(x: Output[QArray[QBit]]):\n",
    "\n",
    "    allocate(3, x)\n",
    "    hadamard_transform(x)\n",
    "\n",
    "\n",
    "qmod = create_model(main)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4e9bb384-4af0-4ab4-9e2e-2b8ba243ad5e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-05-07T13:25:12.863352Z",
     "iopub.status.busy": "2024-05-07T13:25:12.862385Z",
     "iopub.status.idle": "2024-05-07T13:25:15.253504Z",
     "shell.execute_reply": "2024-05-07T13:25:15.252832Z"
    }
   },
   "outputs": [],
   "source": [
    "from classiq import synthesize, write_qmod\n",
    "\n",
    "write_qmod(qmod, \"hadamard_transform\")\n",
    "qprog = synthesize(qmod)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
